package com.gg.user.gguser.dao;

import com.gg.user.gguser.dataobject.GgSearchDataobject;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author yangxinlei
 * @date 2020/4/28
 */
@Mapper
@CacheNamespace
public interface GgSearchMapper {

    @Select("select gg_c_name as ggCName,gg_c_username as ggCUsername,gg_c_phone as ggCPhone,gg_c_youxiang as ggCYouxiang from gg_company where instr(gg_c_name,#{q})>0  order by gg_updatetime desc limit #{page},#{pageNumber}")
    List<GgSearchDataobject> getSearch(@Param("q")String q,@Param("page")Integer page,@Param("pageNumber")Integer pageNumber);

    @Select("select count(gg_c_name) from gg_company where instr(gg_c_name,#{q})>0 ")
    Integer getSearchCount(@Param("q")String q);

    //    APP 首页推荐
    @Select("select id ,gg_c_name as ggCName,gg_c_username as ggCUsername,gg_c_phone as ggCPhone,gg_c_youxiang as ggCYouxiang from gg_company  order by gg_updatetime desc  limit 5")
    List<GgSearchDataobject> getRecommend();


    // 公司搜索
    @Select("select gc.id as id,gc.gg_c_phone as ggCPhone,gc.gg_c_name as ggCName,gc.gg_c_username as ggCUsername,gci.gg_c_i_ziben as ggCITZiben,gci.gg_c_i_zhuceshijian as ggCIZhuceshijian from gg_company gc  left join gg_company_items  gci on gc.id = gci.gg_c_id limit #{page},#{pageNumber}")
    List<Map<Object,Object>> getCompanySearch(@Param("page")Integer page,@Param("pageNumber")Integer pageNumber);

}
